package addon.w3.mdx.com;

import java.io.IOException;

import addon.w3.mdx.LEDataInputStream;
import addon.w3.mdx.MDXException;
import addon.w3.mdx.MDXParentCOM;

/**
KGRT						// [Rotation]
	long	nunks;
	long	LineType;			(0:don't interp;1:linear;2:hermite;3:bezier)
	long	GlobalSeqId;			// 0xFFFFFFFF if none
	struct {
		long	Frame;
		float	a, b, c, d;
		if (LineType > 1) {
			float	InTana, InTanb, InTanc, InTand;
			float	OutTana, OutTanb, OutTanc, OutTand;
		}
	} rotation[nunks];
 * @author madjk
 *
 */
public class MDXRotation extends MDXParentCOM {
	String tag = "KGRT";
	String subTag = "KGRT:Rotation";
	int nunks = -1;
	public int lineType = -1;
	public int globalSeqID = -1;

	public MDXRotationCOM mdcoms[] = null;
	
	public MDXRotation() {
	}
	
	public MDXRotation(String tag,String subTag) {
		this.tag = tag;
		this.subTag = subTag;
	}
	
	public String getTag() {
		return tag;
	}
	
	public void _decode(LEDataInputStream ins) throws IOException, MDXException {
		nunks = ins.readInt();
		lineType = ins.readInt();
		globalSeqID = ins.readInt();
		mdcoms = new MDXRotationCOM[nunks];
		for (int i = 0; i < mdcoms.length; i++) {
			mdcoms[i] = new MDXRotationCOM(subTag, lineType);
			mdcoms[i].decode(ins);
		}
	}
		
	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append("TAG : "+getTag());
		sb.append("\n\tNUNKS : "+nunks);
		sb.append("\n\tLINETYPE : "+lineType);
		sb.append("\n\tGLOBALSEQID : "+globalSeqID);
		if(mdcoms != null && mdcoms.length > 0) sb.append("\n\tROTATIONS[] : "+mdcoms.length);
		return sb.toString();
	}

	@Override
	public boolean isImplicitTag() {
		// TODO Auto-generated method stub
		return false;
	}
}